package com.rutas.java;

import java.io.IOException;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;


public class splash extends Activity {
	
	private static final int SPLASH_DISPLAY_LENGHT = 3000;
	public BaseDatos bd;	//Base de datos
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        	//crea la base de datos
	       bd = new BaseDatos(this);
	   	 	try {
				bd.crearBaseDatos();
			} catch (IOException e) {
				e.printStackTrace();
				Log.d("Splash/BaseDatos", e.toString());
				finish();
			}
	   	 	bd.close();
	        //TODO comprobar si hay nueva base de datos
	        //			if nueva bd -> descargarla en assets
	        //						if true bd.borraBaseDatos();
	        //							bd.crearBaseDatos();
        
        Thread splashThread = new Thread(){
        	@Override
        	public void run(){
        		try{
        			sleep(SPLASH_DISPLAY_LENGHT);
        		}catch(InterruptedException e){
        			//NADA
        		}finally{
        			finish();
        			startActivity(new Intent(getApplicationContext(), Welcome.class));
        			//stop();
        		}
        	}
        };
        splashThread.start();
	}
}
